package com.upb.webserver.chainorg;

import com.upb.webserver.common.pojo.base.BasePageResponse;
import com.upb.webserver.common.tools.JsonUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Log4j2
@RestController
@RequestMapping(value = "chain-org")
public class ChainOrgController {
    @Autowired
    private ChainOrgService chainOrgService;


    @GetMapping(value = "/list")
    public BasePageResponse queryChainOrgByPage(@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                                @RequestParam(value = "pageSize", required = false, defaultValue = "50") Integer pageSize,
                                                @RequestParam(value = "orgType", required = false) Byte orgType,
                                                @RequestParam(value = "chainId") Integer chainId) {
        log.info("start exec method [queryChainOrgByPage]. pageNumber:{} pageSize:{} orgType:{} chainId:{}", pageNumber, pageSize, orgType, chainId);
        BasePageResponse response = chainOrgService.queryChainOrgByPage(pageNumber, pageSize,orgType, chainId);
        log.info("success exec method [queryChainOrgByPage]. result:{}", JsonUtils.objToString(response));
        return response;
    }
}